home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2584 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.3 KB

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: *Pointer to Functions();   /* HELP */
  5. Date: 22 Jan 1996 15:50:51 GMT
  6. Organization: Los Alamos National Laboratory
  7. Message-ID: <TANMOY.96Jan22085051@qcd.lanl.gov>
  8. References: <4dvrq8$c2c@news.unicomp.net>
  9. NNTP-Posting-Host: qcd.lanl.gov
  10. Mime-Version: 1.0
  11. Content-Type: text
  12. In-reply-to: jgore@conline.com's message of 22 Jan 1996 11:18:32 GMT
  13.  
  14. --text follows this line--
  15. In article <4dvrq8$c2c@news.unicomp.net> jgore@conline.com
  16. (Jerry_Gore) writes: 
  17. <snip>
  18.        void    InstallTimer0(WORD period,void far (*func)(void));
  19. <snip>
  20.        void far animate(void)    /* I added 'far' for no good reason.   */
  21.        {                         /* It uses that name in InstallTimer0. */ 
  22.        /* do what ever */        
  23.        return;
  24.        }
  25.  
  26.    How do I send InstallTimer0 the pointer to my function animate ???
  27.    I tried:
  28.  
  29.     InstallTimer0(120 , (*animate)());
  30.  
  31. First, with the far in place, I cannot answer: the code is a syntax
  32. error in C, and every conformant C compiler has to diagnose it as
  33. such. I shall assume that the far is missing from both places. After
  34. the required diagnosis, or if called to compile in a non-conformant
  35. mode, it can accept the above and do whatever it feels like with it.
  36.  
  37. The next question you can ask is how do you create a pointer from a
  38. nonpointer? The most obvious way is to apply the address of `&'
  39. operator. Did you try that? InstallTimer0(120,&animate) should have
  40. worked just fine.
  41.  
  42.    But of course, this does not work and neither did anything else!
  43.    What do I do ???
  44.  
  45. In fact `neither did anything else' is very vague. I could have tried
  46. to figure out your basic confusion had you shown me what else you
  47. tried. In any case, InstallTimer0(120,animate) is probably the
  48. simplest way to do what you want.
  49.  
  50. Cheers
  51. Tanmoy
  52. --
  53. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  54. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  55. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  56. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  57. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  58. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  59.